home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993 October: Windmill on DISC / ADC Developer CD (1993-10) (''Windmill On DISC'')_iso / Dev.CD Oct 93.iso / System Software / U.S. System Software / System 7 Pro™ Beta 11 / Development Tools / Sample Code / Standard Mail / CollaboDraw (w⁄DigiSign) / trapavailable.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-11  |  1.5 KB  |  75 lines  |  [TEXT/MPS ]

  1. /*-------------------------------------------------------------------------------------
  2.  *
  3.  * Simple Sample AOCE Application Framework
  4.  *
  5.  * ©1991-1993 Apple Computer
  6.  *
  7.  -------------------------------------------------------------------------------------*/
  8. /*
  9.  * trapavailable.c -- checks to see if a trap is implemented
  10.  *
  11.  * change history:
  12.  *
  13.  * SJF        04/21/93        1.0b2        update to b2
  14.  * SJF        03/01/93        1.0b1        added digital signatures
  15.  * SJF        02/09/93        1.0b1        update to b1
  16.  * SJF        10/13/92        1.0d4        update to a11
  17.  * SJF        09/09/92        1.0d3        update to a9
  18.  * SJF        05/07/92        1.0d2        update to a6
  19.  * SJF        11/06/91        1.0d1        initial coding
  20.  *
  21.  */
  22.  
  23. #ifndef __TYPES__
  24. #include <Types.h>
  25. #endif
  26.  
  27. #ifndef __TRAPS__
  28. #include <Traps.h>
  29. #endif
  30.  
  31. #ifndef __OSUTILS__
  32. #include <OSUtils.h>
  33. #endif
  34.  
  35. #ifndef __GESTALTEQU__
  36. #include <GestaltEqu.h>
  37. #endif
  38.  
  39. #include "trapavailable.h"
  40.  
  41. short NumToolboxTraps(void);
  42. TrapType GetTrapType(short theTrap);
  43.     
  44. short NumToolboxTraps(void)
  45. {
  46.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  47.         return 0x0200;
  48.     else
  49.         return 0x0400;
  50. }
  51.  
  52. TrapType GetTrapType(short theTrap)
  53. {
  54.     if ((theTrap & 0x0800) > 0)
  55.         return ToolTrap;
  56.     else
  57.         return OSTrap;
  58. }
  59.  
  60. Boolean    TrapAvailable(short theTrap)
  61. {
  62.     TrapType tType;
  63.     Boolean isAvail;
  64.     
  65.     tType = GetTrapType(theTrap);
  66.     if (tType == ToolTrap)
  67.         {
  68.             theTrap &= 0x07FF;
  69.             if (theTrap >= NumToolboxTraps())
  70.                 theTrap = _Unimplemented;
  71.         }
  72.     
  73.     isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  74.     return isAvail;
  75. }